#include "stdafx.h"
#include <iostream>
#include "DetourFunction.h"
#include "Stream.h"





void WATCH_API  test_DetourVariant()
{
	try{
	int x=0;
	DetourVariant vi(x);
	tcout << vi.strValue() << std::endl;
	DetourVariant vl(2l);
	tcout << vl.strValue() << std::endl;
	DetourVariant vp(&x,1);
	tcout << vp.strValue() << std::endl;
	DetourVariant vs(_T("abc"));
	tcout << vs.strValue() << std::endl;

	DetourFunction fun(_T("test"));

	fun.Meta()+=_T("vi");//+=_T("vl")+=_T("vp")+=_T("vs");
	fun.Args()+=vi+=vl+=vp+=vs;

	std::cout << _T("SRC:")<< format(fun.m_pArgs->strList()) << std::endl;

	TCHAR *szFile = _T("test.bin");
	ValueStream *strm = new  BinaryStream(new FileStream(szFile, true));

	fun.Write(strm);

	strm->Close();


	strm = new BinaryStream(new FileStream(szFile, false));

	DetourFunction fun2;

	fun2.Read(strm);

	strm->Close();

	tcout << _T("DST:")<< format(fun.m_pArgs->strList()) << std::endl;

	DetourVariant::Release(fun2.m_pArgs);

	}catch(CFileExException &fee)
	{
		tcout<<fee.GetWinErrorMsg();
	}
}